/*
* @(#)StepInformationWindow.java
*
* Copyright (c) 2004 DCIVision Ltd
* All rights reserved.
*
* This software is the confidential and proprietary information of DCIVision
* Ltd ("Confidential Information").  You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the license
* agreement you entered into with DCIVision Ltd.
*/

package com.dcivision.workflow.applet.editor;

import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.jgraph.graph.DefaultEdge;
import org.jgraph.pad.GPUserObject;

import com.dcivision.framework.Utility;
import com.dcivision.workflow.applet.AppletConstant;
import com.dcivision.workflow.applet.AppletResource;

/**
    StepInformationWindow.java

    @author          Zealot
    @company         DCIVision Limited
    @creation date   27/08/2004
    @version         $Revision: 1.3 $
    */

public class CustomConnectionWindow extends JDialog {
  JPanel panel1 = new JPanel();
  JLabel jLabel1 = new JLabel();
  JTextField jTFRouteName = new JTextField();
  JButton jButton1 = new JButton();
  DefaultEdge edge = null;

  public CustomConnectionWindow(Frame frame, String title, boolean modal) {
    super(frame, title, modal);
    try {
      jbInit();
      pack();
    }
    catch(Exception ex) {
      ex.printStackTrace();
    }
  }

  public CustomConnectionWindow() {
    this(null, "", false);
  }
  
  private void jbInit() throws Exception {
    panel1.setLayout(null);
    jLabel1.setText(AppletResource.lableArr[160]+":");
    jLabel1.setBounds(new Rectangle(26, 27, 92, 22));
    jTFRouteName.setText("");
    jTFRouteName.setBounds(new Rectangle(135, 28, 120, 24));
    jButton1.setBounds(new Rectangle(91, 80, 91, 25));
    jButton1.setText(AppletResource.lableArr[24]);
    jButton1.addActionListener(new CustomConnectionWindow_jButton1_actionAdapter(this));
    this.getContentPane().add(panel1, BorderLayout.CENTER);
    panel1.add(jLabel1, null);
    panel1.add(jTFRouteName, null);
    panel1.add(jButton1, null);
  }

  void jButton1_actionPerformed(ActionEvent e) {
    String routeName = jTFRouteName.getText();
    if(Utility.isEmpty(routeName)){
      return;
    }
    GPUserObject connectType = new GPUserObject();
    connectType.putProperty("TYPE","U"+AppletConstant.SPLITCHAR+routeName);
    connectType.setValue(routeName);
    this.edge.setUserObject(connectType);
    this.dispose();

  }
  
  public DefaultEdge getEdge(){
    return this.edge;    
  }
  
  public void setEdge(DefaultEdge edge){
    this.edge = edge;    
  }
}

class CustomConnectionWindow_jButton1_actionAdapter implements java.awt.event.ActionListener {
  CustomConnectionWindow adaptee;

  CustomConnectionWindow_jButton1_actionAdapter(CustomConnectionWindow adaptee) {
    this.adaptee = adaptee;
  }
  public void actionPerformed(ActionEvent e) {
    adaptee.jButton1_actionPerformed(e);
  }
}